package com.openingedu.mba.entity;

import java.util.ArrayList;
import java.util.List;

import com.j256.ormlite.dao.ForeignCollection;
import com.openingedu.mba.persist.DbQuestion;
import com.openingedu.mba.persist.DbQuestionOption;
import com.openingedu.mba.persist.DbQuestionSeckill;
import com.openingedu.mba.persist.DbQuestionSolution;

public class QuestionVO {

	private Integer id;
	private String questionSerial;
	private Integer questionType;
	private Integer questionIndex;
	private String questionTitle;
	private String questionSummary;
	private Short questionStatus;
	private String questionTag;
	private String questionImage;
	private String questionImage1;
	private String questionImage2;
	/** 是否完成 **/
	private boolean finish;
	/** 是否正确 **/
	private boolean correct;
	
	private List<QuestionOptionVO> questionOptions;
	private List<QuestionSolutionVO> questionSolutions;
	private List<QuestionSeckillVO> questionSeckills;

	public QuestionVO() {
		
	}
	
	public QuestionVO(DbQuestion dbQuestion) {
		questionOptions = new ArrayList<QuestionOptionVO>();
		questionSolutions = new ArrayList<QuestionSolutionVO>();
		questionSeckills = new ArrayList<QuestionSeckillVO>();
		setId(dbQuestion.getQuestionID());
		setQuestionIndex(dbQuestion.getQuestionIndex());
		setQuestionSerial(dbQuestion.getQuestionSerial());
		setQuestionStatus(dbQuestion.getQuestionStatus());
		setQuestionSummary(dbQuestion.getQuestionSummary());
		setQuestionTag(dbQuestion.getQuestionTag());
		setQuestionTitle(dbQuestion.getQuestionTitle());
		setQuestionType(dbQuestion.getQuestionType());
		setQuestionImage(dbQuestion.getQuestionImage());
		setQuestionImage1(dbQuestion.getQuestionImage1());
		setQuestionImage2(dbQuestion.getQuestionImage2());
		
		ForeignCollection<DbQuestionOption> options = dbQuestion.getQuestionOptions();
		for (DbQuestionOption dbQuestionOption : options) {
			QuestionOptionVO questionOption = new QuestionOptionVO();
			questionOption.setId(dbQuestionOption.getOptionID());
			questionOption.setOptionContent(dbQuestionOption.getOptionContent());
			questionOption.setOptionCorrect(dbQuestionOption.getOptionCorrect());
			questionOptions.add(questionOption);
		}
		
		ForeignCollection<DbQuestionSolution> solutions = dbQuestion.getQuestionSolutions();
		for (DbQuestionSolution dbQuestionSolution : solutions) {
			QuestionSolutionVO questionSolution = new QuestionSolutionVO();
			questionSolution.setId(dbQuestionSolution.getId());
			questionSolution.setSolutionContent(dbQuestionSolution.getSolutionContent());
			questionSolutions.add(questionSolution);
		}
		
		ForeignCollection<DbQuestionSeckill> seckills = dbQuestion.getQuestionSeckills();
		for (DbQuestionSeckill dbQuestionSeckill : seckills) {
			QuestionSeckillVO questionSeckill = new QuestionSeckillVO();
			questionSeckill.setId(dbQuestionSeckill.getId());
			questionSeckill.setSeckillContent(dbQuestionSeckill.getSeckillContent());
			questionSeckills.add(questionSeckill);
		}
	}
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getQuestionSerial() {
		return questionSerial;
	}

	public void setQuestionSerial(String questionSerial) {
		this.questionSerial = questionSerial;
	}

	public Integer getQuestionType() {
		return questionType;
	}

	public void setQuestionType(Integer questionType) {
		this.questionType = questionType;
	}

	public Integer getQuestionIndex() {
		return questionIndex;
	}

	public void setQuestionIndex(Integer questionIndex) {
		this.questionIndex = questionIndex;
	}

	public String getQuestionTitle() {
		return questionTitle;
	}

	public void setQuestionTitle(String questionTitle) {
		this.questionTitle = questionTitle;
	}

	public String getQuestionSummary() {
		return questionSummary;
	}

	public void setQuestionSummary(String questionSummary) {
		this.questionSummary = questionSummary;
	}

	public Short getQuestionStatus() {
		return questionStatus;
	}

	public void setQuestionStatus(Short questionStatus) {
		this.questionStatus = questionStatus;
	}

	public String getQuestionTag() {
		return questionTag;
	}

	public void setQuestionTag(String questionTag) {
		this.questionTag = questionTag;
	}

	public String getQuestionImage() {
		return questionImage;
	}

	public void setQuestionImage(String questionImage) {
		this.questionImage = questionImage;
	}

	public String getQuestionImage1() {
		return questionImage1;
	}

	public void setQuestionImage1(String questionImage1) {
		this.questionImage1 = questionImage1;
	}

	public String getQuestionImage2() {
		return questionImage2;
	}

	public void setQuestionImage2(String questionImage2) {
		this.questionImage2 = questionImage2;
	}

	public List<QuestionOptionVO> getQuestionOptions() {
		return questionOptions;
	}

	public void setQuestionOptions(List<QuestionOptionVO> questionOptions) {
		this.questionOptions = questionOptions;
	}

	public List<QuestionSolutionVO> getQuestionSolutions() {
		return questionSolutions;
	}

	public void setQuestionSolutions(List<QuestionSolutionVO> questionSolutions) {
		this.questionSolutions = questionSolutions;
	}

	public List<QuestionSeckillVO> getQuestionSeckills() {
		return questionSeckills;
	}

	public void setQuestionSeckills(List<QuestionSeckillVO> questionSeckills) {
		this.questionSeckills = questionSeckills;
	}

	public boolean isFinish() {
		return finish;
	}

	public void setFinish(boolean finish) {
		this.finish = finish;
	}

	public boolean isCorrect() {
		return correct;
	}

	public void setCorrect(boolean correct) {
		this.correct = correct;
	}

	@Override
	public String toString() {
		return "Question [id=" + id + ", questionSerial=" + questionSerial
				+ ", questionType=" + questionType + ", questionIndex="
				+ questionIndex + ", questionTitle=" + questionTitle
				+ ", questionSummary=" + questionSummary + ", questionStatus="
				+ questionStatus + ", questionTag=" + questionTag
				+ ", questionImage=" + questionImage + ", questionImage1="
				+ questionImage1 + ", questionImage2=" + questionImage2
				+ ", questionOptions=" + questionOptions
				+ ", questionSolutions=" + questionSolutions
				+ ", questionSeckills=" + questionSeckills + "]";
	}

}
